package com.neusoft.acap.bigdata.test.hbase.util;

import java.util.Calendar;

import org.junit.Test;

/**
 * 用于计算时间间隔范围的工具类
 * 
 * @author lihzh
 * @alia OneCoder
 * @date 2012-11-19 下午10:32:46
 */
public class TimeRangeUtil {

	/**
	 * 计算时间间隔点
	 * 
	 * @param startTime
	 * @param endTime
	 * @param pointCount
	 * @return
	 * @author OneCoder(OneCoder)
	 * @date 2012-11-19 下午10:34:25
	 */
	public static long[] calTimeRangePoint(long startTime, long endTime, int pointCount) {
		long pointGap = (endTime - startTime) / (pointCount - 1);
		long[] divisionPoints = new long[pointCount - 1];
		for (int i = 0; i < pointCount - 1; i++) {
			divisionPoints[i] = startTime + (i * pointGap);
		}
		return divisionPoints;
	}

	@Test
	public void testGetTime() {
		printTime(1320163200000L);
		printTime(1320249600000L);
		printTime(1320336000000L);
		printTime(1320422400000L);
		printTime(1321977600000L);
	}

	private void printTime(long time) {
		Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(time);
		System.out.print("Year: " + cal.get(Calendar.YEAR) + " Month: " + cal.get(Calendar.MONTH) + " Day: "
				+ cal.get(Calendar.DAY_OF_MONTH));
		System.out.println();
	}

}
